<!DOCTYPE html>
<html
      xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorate="~{common/base}">

<!--公共CSS JS引用-->
<head th:include="/common/head :: commonHead('用户管理')"></head>
<body>
<!--自定义的页面内容-->
<div layout:fragment="index">

    <!--自定义JS-->
    <script th:src="@{~/js/biz/dataTables.js}" th:inline="javascript" type="text/javascript"></script>
    <script th:src="@{~/js/biz/user.js}" th:inline="javascript" type="text/javascript"></script>

    <script type="text/javascript">
        $(function () {
            User.initUpload();
            DataTables.userTable();
        });
    </script>

    <section class="content-header">
        <h1>
            系统管理
            <small>用户管理</small>
        </h1>
    </section>

    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header">
                        <h3 class="box-title">用户管理</h3>
                    </div>
                    <div class="box-body">

                        <button class="btn btn-default" onclick="User.showAdduser();"><i class='glyphicon glyphicon-new-window'>添加</i></button>
                        <br>
                        <br>
                        <table id="userTable" class="table table-bordered table-striped" style="width: 100%">

                        </table>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!--添加Modal-->
    <div class="modal fade" id="addUser">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close" onclick="User.formReset();">
                        <span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">添加用户</h4>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" id="userForm">
                        <input id="id" name="id" type="hidden">
                        <div class="box-body">
                            <div class="form-group">
                                <label for="username" class="col-sm-2 control-label">用户名</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="username" name="username" placeholder="请输入用户名">
                                </div>
                            </div>
                            <div class="form-group" id="div_pwd">
                                <label for="password" class="col-sm-2 control-label">密码</label>
                                <div class="col-sm-10">
                                    <input type="password" class="form-control" id="password" name="password" placeholder="请输入用户密码">
                                </div>
                            </div>
                            <div class="form-group">
                                <label  class="col-sm-2 control-label">性别</label>
                                <div class="col-sm-10">
                                    <input type="radio" name="sex" value="男">男
                                    <input type="radio" name="sex" value="女"> 女
                                </div>
                            </div>

                            <div class="form-group">
                                <label for="phone" class="col-sm-2 control-label">电话</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="phone" name="phone" placeholder="请输入电话">
                                </div>
                            </div>

                            <div class="form-group">
                                <label for="address" class="col-sm-2 control-label">地址</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="address" name="address" placeholder="请输入地址">
                                </div>
                            </div>

                            <div class="form-group">
                                <label for="idCard" class="col-sm-2 control-label">身份证</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="idCard" name="idCard" placeholder="请输入身份证号码">
                                </div>
                            </div>

                            <div class="form-group">
                                <label for="idCard" class="col-sm-2 control-label">用户图片</label>
                                <div class="col-sm-10">
                                    <input id="files" name="files" type="file">
                                </div>
                                <input type="hidden" name="img" id="img">
                            </div>

                            <div class="form-group">
                                <label for="description" class="col-sm-2 control-label">用户描述</label>
                                <div class="col-sm-10">
                                    <textarea type="text" class="form-control" id="description" name="description" placeholder="请输入描述"></textarea>
                                </div>
                            </div>

                            <div class="form-group">
                                <label  class="col-sm-2 control-label">角色</label>
                                <div class="col-sm-10">
                                    <span th:each="role:${roles}">
                                         <input type="checkbox" name="roleIds" th:value="${role.id}">
                                         <span th:text="${role.description}"></span>
                                    </span>

                                </div>
                            </div>

                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default pull-left" data-dismiss="modal" onclick="User.formReset();">关闭</button>
                    <button type="button" class="btn btn-primary" onclick="User.saveUser()">保存</button>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>